package com.eva.androidlibrary.utils;

import android.content.Context;
import android.content.res.Resources;

public class ResourceUtil {

    /**
     * 反射得到资源id
     * 
     * @param context
     * @param key
     *            传入参数,如"R.drawable.ic_launcher", "R.id.textview"
     * @return
     */
    public static int getResourceId(Context context, String key) {
        String[] keys = key.split("\\.");
        Resources res = context.getResources();
        return res.getIdentifier(keys[2], keys[1], context.getPackageName());
    }

}